import { RMIObject } from "./RMIObject";
import { RMIConfig } from "./RMIConfig";
import { Session } from "./Session";
import { Context } from "./Context";
import { SRMICall } from "./SRMICall";
type int = number;
//class RMIProxyObject

/**
 * 自带session,timeout
 * 提供创建context,call
 */
export class RMIProxyObject extends RMIObject {
  constructor() {
    
    super();this._timeOut = RMIConfig.DefultTimeOut;
  }

  public get session(): Session {
    return this._session;
  }

  public bindingSession(session: Session): void {
    this._session = session;
    return;
  }

  public set timeOut(arg1: int) {
    this._timeOut = arg1;
    return;
  }

  public get timeOut(): int {
    return this._timeOut;
  }

  public makeContext(session: Session): Context {
    var context = new Context();
    context._session = session;
    context._connection = session.connection;
    context._timeOut = this._timeOut;
    return context;
  }

  public makeCall(operation: string): SRMICall {
    var srmiCall = new SRMICall();
    srmiCall.identity = this.identity;
    srmiCall.operation = operation;
    return srmiCall;
  }

  private _session!: Session;

  private _timeOut: int;
}
